/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * BillingPanel.java
 *
 * Created on Nov 9, 2010, 8:49:25 AM
 */

package lmclogistics;

import components.Lightbox;
import components.Button;
import components.NButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;

/**
 *
 * @author Sonia Tan
 */
public class BillingPanel extends javax.swing.JPanel {

    /** Creates new form SummaryPanel */

    private int j = 0;
    private Button billingSubmenu[] = new Button[2];
    private JPanel pl;

    public BillingPanel() {
        initComponents();
        initSumMenus();
        setOpaque(false);
        setLocation(613, 165);
        setSize(287, 375);
        initButtons();
        setLayout(null);
    }

    public void setSumButton(String button,String rollover,int x, int y){
        billingSubmenu[j] = new Button(button,291,37);
        billingSubmenu[j].setLocation(x,y);
        billingSubmenu[j].setRollover(rollover);
        add(billingSubmenu[j]);
        j++;


    }

    public void initSumMenus(){
        setSumButton("salesinvoice button.png","salesinvoice button selected.png",0,0);
        setSumButton("noninvoice button.png","noninvoice button selected.png",0,40);
  


    }

     public void initButtons(){

        billingSubmenu[0].addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                for(int i=0;i<j;i++)
                       billingSubmenu[i].setVisible(false);

                       setSize(919,577);
                       setLocation(0,0);

                       SalesInvoice sales= new SalesInvoice();

                       Main.login.disableButtons();

                        pl = new Lightbox(sales);
                        add(pl, 1);

                        NButton close = new NButton("Close",620,480);
                        pl.add(close,0);
                        close.addActionListener(new ActionListener(){
                            public void actionPerformed(ActionEvent e) {
                            remove(pl);
                            setDefault();
                            repaint();
                            Main.login.enableButtons();
                            }

                });
                NButton ok = new NButton("OK",535,480);
                        pl.add(ok,0);
                        close.addActionListener(new ActionListener(){
                            public void actionPerformed(ActionEvent e) {
                            remove(pl);
                            setDefault();
                            repaint();
                            Main.login.enableButtons();
                            }

                });

            }
        });

        billingSubmenu[1].addActionListener(new ActionListener(){

            public void actionPerformed(ActionEvent e) {
                for(int i=0;i<j;i++)
                       billingSubmenu[i].setVisible(false);

                       setSize(919,577);
                       setLocation(0,0);

                       NonInvoice sales= new NonInvoice();

                       Main.login.disableButtons();

                        pl = new Lightbox(sales);
                        add(pl, 1);

                        NButton close = new NButton("Close",620,480);
                        pl.add(close,0);
                        close.addActionListener(new ActionListener(){
                            public void actionPerformed(ActionEvent e) {
                            remove(pl);
                            setDefault();
                            repaint();
                            Main.login.enableButtons();
                            }

                });
                NButton ok = new NButton("OK",535,480);
                        pl.add(ok,0);
                        close.addActionListener(new ActionListener(){
                            public void actionPerformed(ActionEvent e) {
                            remove(pl);
                            setDefault();
                            repaint();
                            Main.login.enableButtons();
                            }

                });
               
        }
        });

       
    }

     public void setDefault(){
            setLocation(613, 165);
            setSize(287, 340);

            for(int i=0;i<j;i++)
            {
                billingSubmenu[i].setVisible(true);
                billingSubmenu[i].setEnabled(true);
            }
        }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

}
